/*
常用的前端控件使用：
    //1.下拉框树结构（支持设置是否允许选择父节点）
    //2.下拉列表三级联动
    //3.Ajax请求
    //4.下拉框
    //5.时间控件(可赋值、可清空)
    //6.文件上传(带预览的图片上传，单文件上传，多文件上传)
    //7.提示弹框
    //8.纯文本框，见test.html
    //9.多行文本输入框，见test.html
    //10.自动补全(可赋值)
    //11.列表
    //12.模态框
    //13.左边栏树
    //14.定时器
    //15.导出
    //16.在AngularJS域外访问域中属性
    //17.缓存，适用于字典、多级联动等情形
    //18.顶部浮动窗口
    //19.angular编译html
 */

var _table;
demoApp.controller('testCtrl', function ($scope,$http,$uibModal,$timeout,$compile) {
    $scope.form = {
        testTreeId: '',
        testTree: '',

        firstCategory:'',
        secondCategory:'',
        thirdCategory:'',

        payType:'',

        time:'',

        category:'',

        text:'',

        textarea:'',

        associateJDCategory:'',
        associateJDCategoryname:'',
    };

    //1.下拉框树结构
    var data = [
        {
            "id":"123h",
            "text": "Parent 1",
            "nodes": [
                {
                    "id":"123g",
                    "text": "Child 1",
                    "nodes": [
                        {
                            "id":"123f",
                            "text": "SubChild 1"
                        },
                        {
                            "id":"123d",
                            "text": "SubChild 2"
                        },
                        {
                            "id":"123s",
                            "text": "SubChild 3"
                        },
                        {
                            "id":"123a",
                            "text": "SubChild 4"
                        }
                    ]
                },
                {
                    "id":"123p",
                    "text": "Child 2"
                },
                {
                    "id":"123o",
                    "text": "Child 3"
                }
            ]
        },
        {
            "id":"123i",
            "text": "Parent 2",
            "nodes": [
                {
                    "id":"123u",
                    "text": "Child 1"
                },
                {
                    "id":"123y",
                    "text": "Child 2"
                },
                {
                    "id":"123t",
                    "text": "Child 3"
                }
            ]
        },
        {
            "id":"123r",
            "text": "Parent 3",
            "nodes": [
                {
                    "id":"123e",
                    "text": "Child 1"
                },
                {
                    "id":"123w",
                    "text": "Child 2"
                },
                {
                    "id":"123q",
                    "text": "Child 3"
                }
            ]
        }
    ];
    //树的初始化
    $("#testTree").treeSelect({id: 'id',textField:'text',childField:'nodes', data: data}, function (node) {
        $scope.form.testTreeId=node.id;
        $scope.form.testTree =node.text;
        //刷新绑定
        $scope.$apply();
        console.log(node);
    },1);

    //2.下拉列表三级联动
    $scope.categoryurl = "http://localhost:10039/product/backSku/getCategoryListByCode";
    $scope.firstList = [];
    $scope.secondList = [];
    $scope.thirdList = [];
    //初始化二级分类
    $scope.initSecondClassification = function() {
        $scope.secondList = [{categoryCode:"",categoryName:"请选择上级分类",sourseCategoryCode:""}];
        $scope.form.secondCategory = $scope.secondList[0].categoryCode;
    }
    //初始化三级分类
    $scope.initThirdClassification = function () {
        $scope.thirdList = [{categoryCode:"",categoryName:"请选择上级分类",sourseCategoryCode:""}];
        $scope.form.thirdCategory = $scope.thirdList[0].categoryCode;
    }
    $scope.initSecondClassification();
    $scope.initThirdClassification();
    /**
     * 获取一级分类
     */
    //3.Ajax请求
    new AjaxHttp($scope.categoryurl, {}, function (data) {
        alert("hahahaha");
        $scope.firstList = [{categoryCode:"",categoryName:"请选择",sourseCategoryCode:""}];
        if (data.code == 0) {
            for(var i in data.data){
                $scope.firstList.push(data.data[i]);
            }
        } else {
            Alert.error(data.msg);
        }
        $scope.$applyAsync();
    },$.ajaxConfig).post();
    /**
     * 一级分类触发事件，根据一级分类code获取二级分类
     */
    $scope.firstCategory=function () {
        $scope.initSecondClassification();
        $scope.initThirdClassification();
        if($scope.form.firstCategory==""){
            return;
        }
        new AjaxHttp($scope.categoryurl, {categoryCode:$scope.form.firstCategory}, function (data) {
            $scope.secondList = [{categoryCode:"",categoryName:"请选择",sourseCategoryCode:""}];
            if (data.code == 0) {
                for(var i in data.data){
                    $scope.secondList.push(data.data[i]);                }

            } else {
                Alert.error(data.msg);
            }
            $scope.$applyAsync($scope.form.secondCategory = $scope.secondList[0].categoryCode);
        },$.ajaxConfig).post();
    };
    /**
     * 二级分类触发事件，根据二级分类code获取三级分类
     */
    $scope.secondCategory=function () {
        $scope.initThirdClassification();
        if($scope.form.secondCategory=="") {
            return;
        }
        new AjaxHttp($scope.categoryurl,{categoryCode:$scope.form.secondCategory}, function (data) {
            $scope.thirdList = [{categoryCode:"",categoryName:"请选择",sourseCategoryCode:""}];
            if (data.code == 0) {
                for(var i in data.data){
                    $scope.thirdList.push(data.data[i]);
                }
            } else {
                Alert.error(data.msg);
            }
            $scope.$applyAsync($scope.form.thirdCategory = $scope.thirdList[0].categoryCode);
        },$.ajaxConfig).post();
    };

    //4.下拉框
    $scope.payType = [{"id":1,"name":"银联"},{"id":2,"name":"支付宝"},{"id":3,"name":"微信"},{"id":4,"name":"ApplePay"},{"id":5,"name":"公对公转账"}];
    $scope.payType.unshift({"name":"请选择","id":""});
    $scope.form.payType='';

    //5.时间控件(允许赋值)
    $timeout(
        function(){
            $scope.form.time = "2017-12-31 23:59:59";
            $scope.$applyAsync();
        },500);

    //6.上传
    //6.1图片上传（带预览，单文件）
    //图片回显
    $scope.showImg = function (){
        var blobUrl = '';
        if($("#file")[0].files[0]){
            blobUrl = URL.createObjectURL($("#file")[0].files[0]);
        }
        $("#imgShow").attr('src', blobUrl);
    }
    //删除已选图片
    $scope.deleteImg = function () {
        $("#imgShow").attr('src', "");
        $("#file")[0].value = "";
    };

    //文件列表
    var files = new Array();
    //6.2其他文件上传(单文件)在html元素中去除multiple属性即可设置不支持多选
    //6.2其他文件上传(单文件)文件名回显
    // $scope.addFiles = function (){
    //     $("#fileList0").remove();
    //     files = new Array();
    //     if($('#file1')[0].files[0]){
    //         files.push($('#file1')[0].files[0]);
    //         addFileNameElement(0);
    //     }
    // };

    //6.3其他文件上传(多文件)
    //6.3其他文件上传(多文件)文件名回显
    $scope.addFiles = function (){
        //数组原始长度
        var index = files.length;
        //文件名回显
        for(var i=0;i<$('#file1')[0].files.length;i++){
            // 将文件添加到数组
            files.push($('#file1')[0].files[i]);
        }
        addFileNameElement(index);
    };
    //其他文件上传,删除已选文件 通用
    $scope.deleteUpFile = function (index) {
        //把从第i个开始的结点全部删除
        for(var i = index;i<files.length;i++) {
            $("#fileList" + i).remove();
        }
        files.splice(index, 1);
        addFileNameElement(index);
    };

    //根据已选文件数组批量添加结点：index:从文件数组第几个开始添加结点；
    function addFileNameElement(index) {
        var html = '';
        for(var i = index;i<files.length;i++){
            html += '<tr id="fileList'+i+'">\n' +
                '<td>\n' +
                '<span>'+buildFileName(files[i].name)+'<i style="color: #367fa9;" class="fa fa-times" ng-click="deleteUpFile('+i+')"></i></span>\n' +
                ' </td>\n' +
                '</tr>\n';
        }
        if(html=='')return;
        //19.angular编译html
        var template = angular.element(html);
        var mobileDialogElement = $compile(template)($scope);
        $('#fileLists').append(mobileDialogElement);
    }

    //6.3上传至服务端
    $scope.save = function () {
        var formData = new FormData();
        formData.append("file", $("#file")[0].files[0]);
        for (var i = 0; i < files.length; i++) {
            formData.append("files", files[i]);
        }
        //formData.getAll("files");
        formData.append("type", "img");
        angular.forEach($scope.form, function (val, key) {
            formData.append(key, val);
        });
        $http.post(url, formData, {
            transformRequest: angular.identity,
            headers: {'Content-Type': undefined}
        }).success(function (result) {
            //7.提示弹框
            Alert.success("成功:"+result.msg);
        }).error(function (result) {
            Alert.error("失败:"+result.msg);
        });
    };

    //8.纯文本框

    //9.多行文本输入框

    //10.自动补全
    $scope.categorys = [{"id":1,"catclass":3,"name":"分类1","parentid":3123,"state":0},{"id":2,"catclass":3,"name":"分类2","parentid":3123,"state":0},{"id":3,"catclass":3,"name":"分类3","parentid":3123,"state":0},{"id":4,"catclass":3,"name":"分类4","parentid":324234,"state":0},{"id":5,"catclass":3,"name":"分类5","parentid":534,"state":0},{"id":6,"catclass":3,"name":"分类6","parentid":45654,"state":0},{"id":7,"catclass":3,"name":"分类7","parentid":1323,"state":0},{"id":8,"catclass":8,"name":"分类8","parentid":132,"state":0},{"id":9,"catclass":9,"name":"分类9","parentid":132,"state":0}];
    //10.1.自动补全 获取已选定的id及name
    // $scope.form.associateJDCategory = $scope.category.originalObject.id;
    // $scope.form.associateJDCategoryName = $scope.category.originalObject.name;
    //10.2.自动补全 赋值
    $timeout(function(){
        $scope.form.category = "分类3";
        $scope.$applyAsync();
    });
    $scope.category = {title: "分类3",originalObject:{id:3,name:"分类3"}};

    //11.列表
    $scope.orderListUrl = $.baseServiceUrl+"/order/backOrders/orderList";
    _table = new PageDataGrid($("#list"), $scope.orderListUrl, {
        // ordering: true,
        // order: [[ 12, "desc" ]],
        columns: [
            {
                data: "", title: "&nbsp;&nbsp;\<input id='chooseAll' type='checkbox' onclick='chooseAll(id)' \>",width: "20px",
                render: function (data, type, row, meta) {
                    var title = "&nbsp;&nbsp;<input type='checkbox' name='check' value='" + row["id"] + "'>";
                    return title;
                }
            },
            {
                data: "subNumber", title: "订单编号",
                // 11.1.列表 编号可点击
                // render: function (data, type, row, meta) {
                //     var title = "<a href=\"javascript:view('" + row["id"] + "');\">"+ data +"</a>";
                //     return title;
                // }
            },
            {   data: "buyerOrganizationName", title: "企业名称"},
            {   data: "buyerName", title: "用户名"},
            {   data: "buyerPhone", title: "手机号码"},
            {   data: "payTime", title: "支付时间"},
            {   data: "finishedTime", title: "完成时间"},
            {   data: "verificationName", title: "核销状态"},
            {   data: "orderStateName", title: "订单状态"},
            {
                data: "operation", title: "操作",
                render: function (data, type, row, meta) {
                    var title = "&nbsp;&nbsp;";
                    title += "<a href=\"javascript:openModalOut('" + row["id"] + "',1);\">打开模态框</a>";
                    return title;
                }
            }
        ],
        //11.2.列表 双击操作
        fnDrawCallback:function () {
            $("#list tbody tr").dblclick(function (e) {
                //获取该行数据
                var aData = _table.table.data()[this.rowIndex-1];
                console.log(aData);
            });
        }
    }, {vo:{}}, $.ajaxConfig);
    // 获取所有已选择的栏目id
    // getAllChoose();

    //12.模态框
    $scope.openModal = function (id) {
        var modalInstance = $uibModal.open({
            templateUrl: 'views/test/testModal.html',
            size:"lg",
            controller: ['$uibModalInstance', '$scope', "$timeout", function ($uibModalInstance, $scope, $timeout) {
                //13.左边栏树
                var orglistModel = [{"id":25,"createdBy":null,"creationDate":"2017-04-10 11:46:52","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-04-12 11:19:32","enabledFlag":1,"code":"AUTH","parentId":0,"displayIndex":5,"left":-277,"right":-126,"level":0,"name":"鉴权中心","systemCode":"AUTH","description":"鉴权中心","type":0,"url":null,"logo":"fa-amazon"},{"id":26,"createdBy":null,"creationDate":"2017-04-10 11:48:51","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-04-10 11:48:51","enabledFlag":1,"code":"AUTH_USER_PERMIT","parentId":25,"displayIndex":0,"left":-276,"right":-135,"level":1,"name":"用户授权","systemCode":"AUTH","description":"鉴权中心","type":0,"url":"http://web.einwin.com/auth/#/user/list","logo":"fa-amazon"},{"id":27,"createdBy":null,"creationDate":"2017-04-10 11:49:51","updatedBy":null,"updationDate":"2017-04-10 11:49:51","enabledFlag":1,"code":"AUTH_MODULE","parentId":25,"displayIndex":0,"left":-274,"right":-133,"level":1,"name":"模块管理","systemCode":"AUTH","description":null,"type":0,"url":"http://web.einwin.com/auth/#/module/list","logo":null},{"id":28,"createdBy":null,"creationDate":"2017-04-10 11:51:23","updatedBy":null,"updationDate":"2017-04-10 11:51:23","enabledFlag":1,"code":"AUTH_ROLE","parentId":25,"displayIndex":0,"left":-272,"right":-131,"level":1,"name":"角色管理","systemCode":"AUTH","description":"角色管理","type":0,"url":"http://web.einwin.com/auth/#/role/list","logo":null},{"id":30,"createdBy":"","creationDate":"2017-04-10 11:53:20","updatedBy":"","updationDate":"2017-04-10 11:53:20","enabledFlag":1,"code":"AUTH_OPERATOR","parentId":25,"displayIndex":0,"left":-270,"right":-129,"level":1,"name":"操作管理","systemCode":"AUTH","description":"操作管理","type":0,"url":"http://web.einwin.com/auth/#/operator/list","logo":""},{"id":40,"createdBy":null,"creationDate":"2017-04-17 11:30:56","updatedBy":null,"updationDate":"2017-04-17 11:30:56","enabledFlag":1,"code":"BDC","parentId":0,"displayIndex":0,"left":-265,"right":-120,"level":0,"name":"基础数据","systemCode":"BDC","description":"基础数据","type":0,"url":null,"logo":"fa fa-database"},{"id":41,"createdBy":null,"creationDate":"2017-04-17 11:32:35","updatedBy":null,"updationDate":"2017-04-17 11:32:35","enabledFlag":1,"code":"BDC_system","parentId":40,"displayIndex":0,"left":-264,"right":-123,"level":1,"name":"系统管理","systemCode":"BDC","description":null,"type":0,"url":"http://web.einwin.com/base/#/system/list","logo":null},{"id":55,"createdBy":null,"creationDate":"2017-05-15 14:39:12","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-15 14:39:12","enabledFlag":1,"code":"VM","parentId":0,"displayIndex":55,"left":-247,"right":-66,"level":0,"name":"投票大会","systemCode":"VM","description":null,"type":0,"url":"http://web.einwin.com/vote/#","logo":null},{"id":56,"createdBy":null,"creationDate":"2017-05-15 14:40:29","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-15 14:40:29","enabledFlag":1,"code":"VMP_ORMT","parentId":55,"displayIndex":1,"left":-246,"right":-77,"level":1,"name":"业主大会","systemCode":"VM","description":"业主大会二级菜单","type":0,"url":null,"logo":null},{"id":68,"createdBy":null,"creationDate":"2017-05-18 14:54:35","updatedBy":"7d3a00ae-4524-4ccf-919f-1ef98d491646","updationDate":"2017-05-18 14:54:35","enabledFlag":1,"code":"VMP_METTING","parentId":56,"displayIndex":1,"left":-245,"right":-82,"level":2,"name":"召开通知","systemCode":"VM","description":null,"type":0,"url":"http://web.einwin.com/vote/#/vote/held/notify/list","logo":null},{"id":100326,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-07-19 14:05:15","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-07-19 14:05:15","enabledFlag":1,"code":"VMP_TPLIST","parentId":56,"displayIndex":1,"left":-243,"right":-80,"level":2,"name":"召开提议","systemCode":"VM","description":null,"type":0,"url":"http://web.einwin.com/vote/#/vote/temporay/meeting/list","logo":null},{"id":100327,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-07-19 14:14:14","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-07-19 14:14:14","enabledFlag":1,"code":"VMP_VOTE","parentId":56,"displayIndex":3,"left":-241,"right":-78,"level":2,"name":"大会投票","systemCode":"VM","description":"大会投票 三级菜单","type":0,"url":"http://web.einwin.com/vote/#/vote/meeting/list","logo":null},{"id":72,"createdBy":null,"creationDate":"2017-05-18 16:34:49","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-18 16:34:49","enabledFlag":1,"code":"VMP_INVESTIGATE","parentId":55,"displayIndex":2,"left":-236,"right":-73,"level":1,"name":"社区意见调查","systemCode":"VM","description":"社区意见调查 二级菜单","type":0,"url":"http://web.einwin.com/vote/#/vote/opinion/list","logo":null},{"id":73,"createdBy":null,"creationDate":"2017-05-18 16:35:24","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-18 16:35:24","enabledFlag":1,"code":"VMP_QUALIFICATION","parentId":55,"displayIndex":3,"left":-234,"right":-71,"level":1,"name":"业主认证","systemCode":"VM","description":"业主认证 二级菜单","type":0,"url":"http://web.einwin.com/vote/#/vote/owners/cert/list","logo":null},{"id":74,"createdBy":null,"creationDate":"2017-05-18 16:40:33","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-18 16:40:33","enabledFlag":1,"code":"VMP_COMMITTEE","parentId":55,"displayIndex":4,"left":-232,"right":-69,"level":1,"name":"业委会","systemCode":"VM","description":"业委会 二级菜单","type":0,"url":"http://web.einwin.com/vote/#/vote/owners/committee/list","logo":null},{"id":75,"createdBy":null,"creationDate":"2017-05-18 16:41:06","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-18 16:41:06","enabledFlag":1,"code":"VMP_USERAUTH","parentId":55,"displayIndex":10,"left":-230,"right":-67,"level":1,"name":"业委会用户授权","systemCode":"VM","description":"业委会用户授权 二级菜单","type":0,"url":"http://web.einwin.com/vote/#/vote/identity/auth/list","logo":null},{"id":100332,"createdBy":null,"creationDate":"2017-08-02 16:47:07","updatedBy":null,"updationDate":"2017-08-02 16:47:07","enabledFlag":1,"code":"AUTH_RULE","parentId":25,"displayIndex":1,"left":-268,"right":-127,"level":1,"name":"数据权限规则","systemCode":"AUTH","description":"数据权限过滤规则定义节点","type":0,"url":"http://web.einwin.com/auth/#/datapermit/list","logo":null},{"id":100319,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-06-08 09:38:23","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-06-08 09:38:23","enabledFlag":1,"code":"BDC_types","parentId":40,"displayIndex":1,"left":-262,"right":-121,"level":1,"name":"分类管理","systemCode":"BDC","description":null,"type":0,"url":"http://web.einwin.com/base/#/type/list","logo":null},{"id":100472,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-11-09 11:43:40","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-11-09 11:43:40","enabledFlag":1,"code":"PLP","parentId":0,"displayIndex":1,"left":-107,"right":-106,"level":0,"name":"公共租赁平台","systemCode":"PLP","description":"公共租赁平台","type":0,"url":null,"logo":null},{"id":100473,"createdBy":"f3d7d619-540c-489b-a92f-fe2150766f91","creationDate":"2017-11-21 10:01:36","updatedBy":"f3d7d619-540c-489b-a92f-fe2150766f91","updationDate":"2017-11-21 10:01:36","enabledFlag":1,"code":"CSCMU","parentId":0,"displayIndex":1,"left":-105,"right":-102,"level":0,"name":"CSC_用户中心","systemCode":"CSCMU","description":null,"type":0,"url":null,"logo":null},{"id":100474,"createdBy":"f3d7d619-540c-489b-a92f-fe2150766f91","creationDate":"2017-11-21 10:06:22","updatedBy":"f3d7d619-540c-489b-a92f-fe2150766f91","updationDate":"2017-11-21 10:06:22","enabledFlag":1,"code":"CSCMC_BUYER","parentId":100473,"displayIndex":2,"left":-104,"right":-103,"level":1,"name":"采购员管理","systemCode":"CSCMU","description":null,"type":0,"url":"http://web.einwin.com/cscmu/#/buyer","logo":null},{"id":100502,"createdBy":"f3d7d619-540c-489b-a92f-fe2150766f91","creationDate":"2017-11-27 10:14:14","updatedBy":"f3d7d619-540c-489b-a92f-fe2150766f91","updationDate":"2017-11-27 10:14:14","enabledFlag":1,"code":"CSCMO","parentId":0,"displayIndex":1,"left":-101,"right":-94,"level":0,"name":"CSC_订单中心","systemCode":"CSCMO","description":null,"type":0,"url":null,"logo":null},{"id":100504,"createdBy":"f3d7d619-540c-489b-a92f-fe2150766f91","creationDate":"2017-11-28 16:52:04","updatedBy":"f3d7d619-540c-489b-a92f-fe2150766f91","updationDate":"2017-11-28 16:52:04","enabledFlag":1,"code":"CSCMO_ORDERLIST","parentId":100502,"displayIndex":1,"left":-100,"right":-99,"level":1,"name":"订单列表","systemCode":"CSCMO","description":null,"type":0,"url":"http://web.einwin.com/cscmo/#/order","logo":null},{"id":100503,"createdBy":"f3d7d619-540c-489b-a92f-fe2150766f91","creationDate":"2017-11-27 10:34:17","updatedBy":"f3d7d619-540c-489b-a92f-fe2150766f91","updationDate":"2017-11-27 10:34:17","enabledFlag":1,"code":"CSCMP","parentId":0,"displayIndex":1,"left":-93,"right":-86,"level":0,"name":"CSC_商品中心","systemCode":"CSCMP","description":null,"type":0,"url":null,"logo":null},{"id":100505,"createdBy":"f3d7d619-540c-489b-a92f-fe2150766f91","creationDate":"2017-11-28 17:00:55","updatedBy":"f3d7d619-540c-489b-a92f-fe2150766f91","updationDate":"2017-11-28 17:00:55","enabledFlag":1,"code":"CSCMP_PRPBUCTLIST","parentId":100503,"displayIndex":1,"left":-92,"right":-91,"level":1,"name":"商品列表","systemCode":"CSCMP","description":null,"type":0,"url":"http://web.einwin.com/cscmp/#/productList","logo":null},{"id":100506,"createdBy":"f3d7d619-540c-489b-a92f-fe2150766f91","creationDate":"2017-11-28 17:08:25","updatedBy":"f3d7d619-540c-489b-a92f-fe2150766f91","updationDate":"2017-11-28 17:08:25","enabledFlag":1,"code":"CSCMP_ADDPRODUCT","parentId":100503,"displayIndex":2,"left":-90,"right":-89,"level":1,"name":"添加商品","systemCode":"CSCMP","description":null,"type":0,"url":"http://web.einwin.com/cscmp/#/addProduct","logo":null},{"id":100508,"createdBy":"f3d7d619-540c-489b-a92f-fe2150766f91","creationDate":"2017-11-28 17:13:57","updatedBy":"f3d7d619-540c-489b-a92f-fe2150766f91","updationDate":"2017-11-28 17:13:57","enabledFlag":1,"code":"CSCMO_AFTERSALE","parentId":100502,"displayIndex":2,"left":-98,"right":-97,"level":1,"name":"售后管理","systemCode":"CSCMO","description":null,"type":0,"url":"http://web.einwin.com/cscmo/#/afterSale","logo":null},{"id":100509,"createdBy":"f3d7d619-540c-489b-a92f-fe2150766f91","creationDate":"2017-11-28 17:15:53","updatedBy":"f3d7d619-540c-489b-a92f-fe2150766f91","updationDate":"2017-11-28 17:15:53","enabledFlag":1,"code":"CSCMO_INVOICE","parentId":100502,"displayIndex":3,"left":-96,"right":-95,"level":1,"name":"发票管理","systemCode":"CSCMO","description":null,"type":0,"url":"http://web.einwin.com/cscmo/#/invoice","logo":null},{"id":100507,"createdBy":"f3d7d619-540c-489b-a92f-fe2150766f91","creationDate":"2017-11-28 17:11:25","updatedBy":"f3d7d619-540c-489b-a92f-fe2150766f91","updationDate":"2017-11-28 17:11:25","enabledFlag":1,"code":"CSCMP_CATEGORY","parentId":100503,"displayIndex":3,"left":-88,"right":-87,"level":1,"name":"商品分类管理","systemCode":"CSCMP","description":null,"type":0,"url":"http://web.einwin.com/cscmp/#/category","logo":null},{"id":45,"createdBy":null,"creationDate":"2017-04-18 17:14:38","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-02 14:36:29","enabledFlag":1,"code":"EINWIN","parentId":0,"displayIndex":40,"left":-259,"right":-116,"level":0,"name":"一应智能","systemCode":"EINWIN","description":"一应智能","type":0,"url":null,"logo":null},{"id":46,"createdBy":null,"creationDate":"2017-04-18 17:15:07","updatedBy":null,"updationDate":"2017-05-02 14:36:43","enabledFlag":1,"code":"EINWIN_DALIYLOG","parentId":45,"displayIndex":0,"left":-258,"right":-117,"level":1,"name":"工作日志","systemCode":"EINWIN","description":"工作日志","type":0,"url":null,"logo":null},{"id":47,"createdBy":null,"creationDate":"2017-04-28 16:57:10","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-04-28 16:57:10","enabledFlag":1,"code":"DLP","parentId":0,"displayIndex":45,"left":-255,"right":-110,"level":0,"name":"工作日志","systemCode":"DLP","description":"工作日志","type":0,"url":null,"logo":null},{"id":63,"createdBy":null,"creationDate":"2017-05-17 18:39:09","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-17 18:39:09","enabledFlag":1,"code":"FWC","parentId":0,"displayIndex":15,"left":-227,"right":-208,"level":0,"name":"流程中心","systemCode":"FWC","description":"流程中心","type":0,"url":null,"logo":null},{"id":64,"createdBy":null,"creationDate":"2017-05-17 18:39:44","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-17 18:39:44","enabledFlag":1,"code":"FWC_CENTER","parentId":63,"displayIndex":1,"left":-226,"right":-57,"level":1,"name":"流程管理","systemCode":"FWC","description":null,"type":0,"url":null,"logo":null},{"id":82,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-05-31 15:16:02","updatedBy":"f3d7d619-540c-489b-a92f-fe2150766f91","updationDate":"2017-05-31 15:16:02","enabledFlag":1,"code":"DLP_LIST","parentId":47,"displayIndex":1,"left":-254,"right":-113,"level":1,"name":"工作日志列表","systemCode":"DLP","description":"工作日志列表","type":0,"url":"http://web.einwin.com/dailylog/#/dailylog/list","logo":null},{"id":79,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-05-27 17:51:24","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-27 17:51:24","enabledFlag":1,"code":"CP","parentId":0,"displayIndex":50,"left":-341,"right":-192,"level":0,"name":"小区说事","systemCode":"CP","description":"小区说事","type":0,"url":null,"logo":null},{"id":80,"createdBy":"f3d7d619-540c-489b-a92f-fe2150766f91","creationDate":"2017-05-27 18:26:28","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-27 18:26:28","enabledFlag":1,"code":"CP_POSTMANAGER","parentId":79,"displayIndex":1,"left":-340,"right":-195,"level":1,"name":"帖子管理","systemCode":"CP","description":null,"type":0,"url":"http://web.einwin.com/cp/#/postList/list","logo":null},{"id":81,"createdBy":"f3d7d619-540c-489b-a92f-fe2150766f91","creationDate":"2017-05-27 18:27:51","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-27 18:27:51","enabledFlag":1,"code":"CP_SENSITIVEWORDLIST","parentId":79,"displayIndex":2,"left":-338,"right":-193,"level":1,"name":"敏感词","systemCode":"CP","description":null,"type":0,"url":"http://web.einwin.com/cp/#/postSensitiveWordsList/list","logo":null},{"id":83,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-05-31 17:05:34","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-31 17:05:34","enabledFlag":1,"code":"NC","parentId":0,"displayIndex":10,"left":-335,"right":-162,"level":0,"name":"消息中心","systemCode":"NC","description":null,"type":0,"url":null,"logo":null},{"id":85,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-05-31 19:10:10","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-31 19:10:10","enabledFlag":1,"code":"NOTIFY_CONFIG","parentId":83,"displayIndex":1,"left":-334,"right":-181,"level":1,"name":"消息配置","systemCode":"NC","description":null,"type":0,"url":null,"logo":null},{"id":86,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-05-31 19:15:30","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-31 19:15:30","enabledFlag":1,"code":"NOTIFY_TEAMPLATE","parentId":85,"displayIndex":1,"left":-333,"right":-188,"level":2,"name":"消息模板管理","systemCode":"NC","description":null,"type":0,"url":"http://web.einwin.com/notify/#/template/list","logo":null},{"id":87,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-05-31 19:16:29","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-31 19:16:29","enabledFlag":1,"code":"NOTIFY_TYPE","parentId":85,"displayIndex":1,"left":-331,"right":-186,"level":2,"name":"消息分类管理","systemCode":"NC","description":null,"type":0,"url":"http://web.einwin.com/notify/#/type/list","logo":null},{"id":88,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-05-31 19:17:18","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-31 19:17:18","enabledFlag":1,"code":"NOTIFY_GATEWAY","parentId":85,"displayIndex":1,"left":-329,"right":-184,"level":2,"name":"消息网关管理","systemCode":"NC","description":null,"type":0,"url":"http://web.einwin.com/notify/#/gateway/list","logo":null},{"id":89,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-05-31 19:20:00","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-31 19:20:00","enabledFlag":1,"code":"NOTIFY_PUSH_REGISTER","parentId":85,"displayIndex":1,"left":-327,"right":-182,"level":2,"name":"注册设备管理","systemCode":"NC","description":null,"type":0,"url":"http://web.einwin.com/notify/#/pushRegister/list","logo":null},{"id":93,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-05-31 19:22:13","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-31 19:22:13","enabledFlag":1,"code":"NOTIFY_CENTER","parentId":83,"displayIndex":1,"left":-316,"right":-163,"level":1,"name":"消息中心","systemCode":"NC","description":null,"type":0,"url":null,"logo":null},{"id":94,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-05-31 19:22:48","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-31 19:22:48","enabledFlag":1,"code":"NOTIFY_CENTER_SMS","parentId":93,"displayIndex":1,"left":-315,"right":-170,"level":2,"name":"短信管理","systemCode":"NC","description":null,"type":0,"url":"http://web.einwin.com/notify/#/smsNotify/list","logo":null},{"id":95,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-05-31 19:23:26","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-31 19:23:26","enabledFlag":1,"code":"NOTIFY_CENTER_APP","parentId":93,"displayIndex":1,"left":-313,"right":-168,"level":2,"name":"App推送管理","systemCode":"NC","description":null,"type":0,"url":"http://web.einwin.com/notify/#/appNotity/list","logo":null},{"id":96,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-05-31 19:23:59","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-31 19:23:59","enabledFlag":1,"code":"NOTIFY_CENTER_IM","parentId":93,"displayIndex":1,"left":-311,"right":-166,"level":2,"name":"IM推送","systemCode":"NC","description":null,"type":0,"url":"http://web.einwin.com/notify/#/imNotify/list","logo":null},{"id":97,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-05-31 19:24:37","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-05-31 19:24:37","enabledFlag":1,"code":"NOTIFY_CENTER_LOG","parentId":93,"displayIndex":1,"left":-309,"right":-164,"level":2,"name":"失败日志","systemCode":"NC","description":null,"type":0,"url":"http://web.einwin.com/notify/#/log/list","logo":null},{"id":100314,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-06-05 14:20:24","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-06-05 14:20:24","enabledFlag":1,"code":"FWC_CENTER_DEFINED","parentId":64,"displayIndex":1,"left":-225,"right":-62,"level":2,"name":"流程定义管理","systemCode":"FWC","description":null,"type":0,"url":"http://web.einwin.com/flow/#/fwcDefined/definedlist","logo":null},{"id":100315,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-06-05 14:20:47","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-06-05 14:20:47","enabledFlag":1,"code":"FWC_TASK","parentId":63,"displayIndex":1,"left":-218,"right":-209,"level":1,"name":"任务管理","systemCode":"FWC","description":null,"type":0,"url":null,"logo":null},{"id":100316,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-06-05 14:20:47","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-06-05 14:21:23","enabledFlag":1,"code":"FWC_TASK_TODO","parentId":100315,"displayIndex":1,"left":-217,"right":-54,"level":2,"name":"待办任务","systemCode":"FWC","description":"","type":0,"url":"http://web.einwin.com/flow/#/task/todoList","logo":""},{"id":98,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-06-01 10:41:27","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-06-01 10:41:27","enabledFlag":1,"code":"SC","parentId":0,"displayIndex":20,"left":-305,"right":-152,"level":0,"name":"调度中心 ","systemCode":"SC","description":"调度中心http://schedule.einwin.com","type":0,"url":null,"logo":null},{"id":99,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-06-01 10:43:37","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-06-01 10:43:37","enabledFlag":1,"code":"SC_TASK","parentId":98,"displayIndex":1,"left":-304,"right":-153,"level":1,"name":"任务调度管理","systemCode":"SC","description":null,"type":0,"url":null,"logo":null},{"id":100,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-06-01 10:50:35","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-06-01 10:50:35","enabledFlag":1,"code":"SC_TASK_REGISTER","parentId":99,"displayIndex":1,"left":-303,"right":-158,"level":2,"name":"任务注册","systemCode":"SC","description":null,"type":0,"url":"http://web.einwin.com/schedule/#/taskInfo/list","logo":null},{"id":101,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-06-01 10:51:36","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-06-01 10:51:36","enabledFlag":1,"code":"SC_TASK_SCHEDULE","parentId":99,"displayIndex":2,"left":-301,"right":-156,"level":2,"name":"任务调度","systemCode":"SC","description":null,"type":0,"url":"http://web.einwin.com/schedule/#/QrtzTriggers/list","logo":null},{"id":102,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-06-01 10:52:24","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-06-01 10:52:24","enabledFlag":1,"code":"SC_TASK_LOG","parentId":99,"displayIndex":3,"left":-299,"right":-154,"level":2,"name":"调度日志","systemCode":"SC","description":null,"type":0,"url":"http://web.einwin.com/schedule/#/taskExecuteLog/list","logo":null},{"id":100330,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-07-24 16:46:11","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-07-24 16:46:11","enabledFlag":1,"code":"ESC","parentId":0,"displayIndex":30,"left":-277,"right":-134,"level":0,"name":"搜索中心","systemCode":"ESC","description":"搜索中心微服务","type":0,"url":null,"logo":null},{"id":100331,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-07-24 16:50:18","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-07-24 16:50:18","enabledFlag":1,"code":"ESC_DATA_IMPORT","parentId":100330,"displayIndex":1,"left":-276,"right":-125,"level":1,"name":"数据导入配置","systemCode":"ESC","description":null,"type":0,"url":"http://web.einwin.com/esc/#/importconfig/list","logo":null},{"id":100341,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-08-10 14:20:21","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-08-10 14:20:21","enabledFlag":1,"code":"FWC_CENTER_MONITOR","parentId":64,"displayIndex":2,"left":-223,"right":-60,"level":2,"name":"流程监控","systemCode":"FWC","description":null,"type":0,"url":"http://web.einwin.com/flow/#/fwcDefined/monitorList","logo":"fa fa-at"},{"id":100342,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-08-10 14:23:02","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-08-10 14:23:02","enabledFlag":1,"code":"FWC_CENTER_STRATEGY","parentId":64,"displayIndex":3,"left":-221,"right":-58,"level":2,"name":"审核人测路","systemCode":"FWC","description":null,"type":0,"url":"http://web.einwin.com/flow/#/strategy/list","logo":null},{"id":100343,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-08-10 14:44:05","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-08-10 14:44:05","enabledFlag":1,"code":"FWC_TASK_COMPLETED","parentId":100315,"displayIndex":2,"left":-215,"right":-50,"level":2,"name":"已办任务","systemCode":"FWC","description":null,"type":0,"url":"http://web.einwin.com/flow/#/task/completeList","logo":null},{"id":100344,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-08-10 14:45:48","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-08-10 14:45:48","enabledFlag":1,"code":"FWC_TASK_START","parentId":100315,"displayIndex":3,"left":-213,"right":-212,"level":2,"name":"流程申请","systemCode":"FWC","description":null,"type":0,"url":"http://web.einwin.com/flow/#/process/startList","logo":null},{"id":100345,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-08-10 14:46:58","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-08-10 14:46:58","enabledFlag":1,"code":"FWC_TASK_ONWAY","parentId":100315,"displayIndex":4,"left":-357,"right":-210,"level":2,"name":"在途任务","systemCode":"FWC","description":null,"type":0,"url":"http://web.einwin.com/flow/#/task/onwayList","logo":null},{"id":100346,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-08-24 09:53:27","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-08-24 09:53:27","enabledFlag":1,"code":"FMC","parentId":0,"displayIndex":25,"left":-261,"right":-116,"level":0,"name":"表单中心","systemCode":"FMC","description":null,"type":0,"url":null,"logo":null},{"id":100347,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-08-24 10:06:37","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-08-24 10:06:37","enabledFlag":1,"code":"FMC_MANAGER","parentId":100346,"displayIndex":1,"left":-260,"right":-117,"level":1,"name":"表单设计管理","systemCode":"FMC","description":null,"type":0,"url":null,"logo":null},{"id":100348,"createdBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","creationDate":"2017-08-24 10:07:44","updatedBy":"509b5b71-174a-4bac-bce1-7cb2bbda64e7","updationDate":"2017-08-24 10:07:44","enabledFlag":1,"code":"FMC_MANAGER_DESIGN","parentId":100347,"displayIndex":1,"left":-259,"right":-118,"level":2,"name":"业务表单设计","systemCode":"FMC","description":null,"type":0,"url":"http://web.einwin.com/form#/ueditor/list","logo":null}
                ];
                //树配置
                $scope.treeConfig = {
                    pid: "parentId",
                    columns: {
                        id: "id",
                        text: "name"
                    },
                    className:"jstree-leftMenu",
                    leaveHide:false,
                    isAjax: false,
                    data: orglistModel
                };
                //树事件
                $scope.treeEvent = {
                    onchange: function (data) {
                        console.log(data.data);
                    }
                };

                $scope.save = function(){
                    console.log("aaaaaa");
                }

                //14.定时器
                $timeout(function(){
                    //待页面加载完后执行，否则无法绑定页面的id
                    //新建树并绑定到#tree
                    new comboTree($('#tree'), {}, $scope.treeConfig, $scope.treeEvent,false);
                });

                $scope.ok = function () {
                    $uibModalInstance.close();
                };

                $scope.cancel = function () {
                    $uibModalInstance.dismiss('cancel');
                };
            }]
        });
        modalInstance.result.then(function (result) {
            //模态框正常关闭时执行
            Alert.success("模态框正常关闭!");
        });
    };

    //15.导出
    $scope.getExportExcelUrl = $.baseServiceUrl + "/order/afterSaleBack/export/excel";
    $scope.export = function () {
        //导出提示 模态框
        $("#dlg_export").modal("show");
        $http({
            url: $scope.getExportExcelUrl,
            method: "POST",
            data:{vo:{}},
            headers: {
                'Content-type': 'application/json',
                "token":$.cookie("accessToken")
            },
            responseType: 'arraybuffer'
        }).success(function (data, status, headers, config) {
            $("#dlg_export").modal("hide");
            var blob = new Blob([data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
            var now=new Date();
            var fileName="列表"+now.getFullYear()+(now.getMonth()+1)+now.getDate()+now.getHours()+now.getMinutes()+now.getSeconds()+now.getMilliseconds()+".xlsx";
            saveAs(blob, fileName);
        }).error(function (data, status, headers, config) {
            $("#dlg_export").modal("hide");
            Alert.error("导出失败！");
        });
    };

    //重置
    $scope.reset = function () {
        $scope.form.testTreeId= '';
        $scope.form.testTree= '';

        // $scope.form.firstCategory = $scope.firstList[0].categoryCode;
        $scope.initSecondClassification();
        $scope.initThirdClassification();

        $scope.form.time="";

        $scope.form.payType='';

        $scope.form.text='';

        $scope.form.textarea='';

        $scope.form.associateJDCategory='';
        $scope.form.associateJDCategoryname='';
        $scope.category={};

        $scope.deleteImg();
        $scope.deleteUpFile();
        //异步刷新绑定
        $scope.$applyAsync();
    }


    /****************************************************************************
     * 18.浮动窗口相关操作
     *****************************************************************************/
    $(window).scroll(rebuildWindow4scroll);
    $(window).resize(rebuildWindow4resize);
    //滚动条位置改变时重画悬浮div的函数
    function rebuildWindow4scroll() {
        var relative = $('.main-header').height();
        var top = $(this).scrollTop();
        $('.levitate-div').offset({top:top<=relative?relative:top});
    }
    //窗体大小改变时重画悬浮div的函数
    function rebuildWindow4resize() {
        //窗体改变时滚动条位置可能会改变
        rebuildWindow4scroll();
        $timeout(function(){
            var width = $(".content-wrapper").width();
            $('.levitate-div').width(width);
        },300);
    }
    rebuildWindow4resize();
    $('.sidebar-toggle').click(rebuildWindow4resize);



});


//16.在AngularJS空间域外访问域中属性
function openModalOut(id) {
    var appElement = document.querySelector('[ng-controller=testCtrl]');
    var $scope = angular.element(appElement).scope();
    $scope.openModal(id);
}

//17.缓存，适用于字典、多级联动等情形
var dict = new dictionary($.crmBaseServiceUrl + '/crm/dictionary');
